import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mapper.SysMenuMapper;
import com.pojo.SystemMenu;
import com.util.TreeUtil;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class testA {

    @Test
    public void test(){
        ClassPathXmlApplicationContext context =new ClassPathXmlApplicationContext("spring.xml");
        SysMenuMapper sysMenuMapper = context.getBean("sysMenuMapper", SysMenuMapper.class);
        List<SystemMenu> allByStatusOrderBySort = sysMenuMapper.findAllByStatusOrderBySort(1);
        List<SystemMenu> systemMenus = TreeUtil.toTree(allByStatusOrderBySort, 0);

        System.out.println(JSON.toJSONString(systemMenus, SerializerFeature.DisableCircularReferenceDetect));
    }
}
